<?php 
/**
 * User
 *
 * PHP version 5
 *
 * @category Controller
 * @version  1.0
 * @author   duonght <duonght@setacinq.com.vn>
 */
App::uses('AppController', 'Controller');
class UsersController extends AppController{
	
	public function login() {
		$sercuritySalt = Configure::read('Security.salt');
		//$password = $memberInfo->code . $loginPassword . $securitySalt;
		echo $pass = Security::hash('admin123456' . $sercuritySalt, 'sha256', true).'<br>';
		echo strlen($pass);
		if ($this->Auth->user()) {
			return $this->redirect($this->Auth->redirect());
		}
		if ($this->request->is('post')) {
			$oldPassword = $this->request->data['Staff']['password'];
			$this->request->data['Staff']['password'] = $this->request->data['Staff']['loginid'].$oldPassword.Configure::read('Security.salt');
	
			if ($this->Auth->login()) {
				return $this->redirect($this->Auth->redirect());
			} else {
				$this->request->data['Staff']['password'] = $oldPassword;
			}
			$this->Session->setFlash(__('please input correct username/password'), 'message');
		}
	
		$this->set('title_for_layout',__('login'));
	}
}
 ?>